﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace HandMade_Q4T_
{
    public partial class Master : System.Web.UI.MasterPage
    {
        C_SanPham sp = new C_SanPham();
        C_XLDL db = new C_XLDL();
        protected void Page_Load(object sender, EventArgs e)
        {
            sp.Load_Repeater(rpt_category, "SELECT * FROM LOAISP");
            Load_CatName(lis_loaisp, "SELECT tenloai FROM LOAISP");
            Load_CatName(lis_chatlieu, "SELECT tencl FROM CHATLIEU");
            Load_CatName(lis_nhacungcap, "SELECT tenncc FROM NHACUNGCAP");
        }

        public void Load_CatName(HtmlGenericControl  id ,string sqlQuery)
        {
            DataTable dt = db.BangDuLieu(sqlQuery);

            var builder = new System.Text.StringBuilder();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                builder.Append(String.Format("<option value='{0}'>", dt.Rows[i][0]));
                id.InnerHtml = builder.ToString();
            }
            
        }
    }
}